package com.zhiche.lisa.bms.service.pay.impl;

import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import com.zhiche.lisa.bms.dao.mapper.pay.PayApplyDtlBillMapper;
import com.zhiche.lisa.bms.dao.model.pay.PayApplyDtlBill;
import com.zhiche.lisa.bms.service.pay.PayApplyDtlBillService;
import com.zhiche.lisa.core.supports.BaseException;
import org.apache.commons.collections4.CollectionUtils;
import org.springframework.stereotype.Service;
import org.springframework.util.ObjectUtils;

import java.util.Collection;
import java.util.List;

/**
 * <p>
 * 支付申请明细表-账单 服务实现类
 * </p>
 *
 * @author hongbo
 * @since 2018-09-27
 */
@Service
public class PayApplyDtlBillServiceImpl extends ServiceImpl<PayApplyDtlBillMapper, PayApplyDtlBill> implements PayApplyDtlBillService {
    @Override
    public List<PayApplyDtlBill> queryPayApplyDtlBillList(Long payId) {
        if (ObjectUtils.isEmpty(payId)) throw new BaseException("支付申请ID,不能为空！");
        EntityWrapper ew = new EntityWrapper<>();
        ew.eq("head_id", payId);
        return this.selectList(ew);
    }

    /**
     * 根据支付申请ID,得到账单列表
     *
     * @param payIdList
     * @return
     */
    @Override
    public List<PayApplyDtlBill> queryPayApplyDtlListByHeadIdList(Collection<Long> payIdList) {
        if (CollectionUtils.isEmpty(payIdList)) {
            throw new BaseException("支付申请ID,不能为空！");
        }
        EntityWrapper ew = new EntityWrapper<>();
        ew.in("head_id", payIdList);
        return this.selectList(ew);
    }

    @Override
    public void deletePayApplyDtlBillList(Long payId) {
        EntityWrapper ew = new EntityWrapper<>();
        ew.eq("head_id", payId);
        this.delete(ew);
    }
}
